'''
=================
limber.views.view
=================

This module contains an abstract class that defines
the view interface.
'''


class AbstractView(object):

    def __init__(self, parent, document):

        self._parent = parent
        self._document = document
        self._title = document.title() if document.title() else ''

    def document(self):
        '''The view document.'''

        return self._document

    def set_document(self, document):
        '''Sets the views document.'''

        self._document = document
        self.emit_new_document_setted(document)

    def title(self):
        '''Returns the view title.'''

        return self._title

    def set_title(self, title):
        '''Sets the views title.'''

        self._title = title
        self.emit_title_changed(title)

    def show(self):
        '''Shows the view.'''

        pass

    def close(self):
        '''Closes the view.'''

        pass

    #Signals emitters
    def emit_new_document_setted(self, document):
        '''Emits all the overloads of the signal "newDocumentSetted".'''

        self.new_document_setted[object].emit(document)
        self.new_document_setted.emit()

    def emit_title_changed(self, title):
        '''Emits all the overloads of the signal "titleChanged".'''

        self.title_changed[unicode].emit(title)
        self.title_changed.emit()